package easy;

public class Solution_2042 {

    public boolean areNumbersAscending(String s) {
        s += " ";
        char[] chars = s.toCharArray();
        int pre = -1;
        for (int i = 0, count = 0; i < chars.length; i++) {
            char c = chars[i];
            if (c >= '0' && c <= '9') {
                count++;
            } else {
                if (count > 0) {
                    int num = 0;
                    for (int j = i - count; j < i; j++) {
                        num *= 10;
                        num += (chars[j] - '0');
                    }
                    //                    System.out.println(num);
                    if (num <= pre) {
                        return false;
                    }
                    pre = num;
                    count = 0;
                }
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Solution_2042 model = new Solution_2042();
        System.out.println(model.areNumbersAscending("1 box has 3 blue 4 red 6 green and 12 yellow marbles"));
        System.out.println(model.areNumbersAscending("hello world 5 x 5"));
        System.out
            .println(model.areNumbersAscending("sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s"));
        System.out.println(model.areNumbersAscending("4 5 11 26"));
    }
}
